<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.io.BufferedWriter" %> 
<%@ page import="java.io.FileWriter" %> 
<%@ page import="java.io.IOException" %>
<%@ page import="model.EvenementenIO" %>
<%@ page import="domein.Evenement" %>
<%@ page import="org.jsoup.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<title>Incentro Event Inviting System</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<link rel="shortcut icon" type="image/x-icon" href="/img/favicon.ico" />
</head>

<body>

	<div id="wrapper">

		<div id="header">
			<a href="./eOverzicht.jsp" id="logo"><img src="img/logo.png" /></a>
		</div>
		
	<%
int eventID = Integer.parseInt(request.getParameter("eventID")); 
EvenementenIO eIo = new EvenementenIO();
Evenement event = eIo.getEvent(eventID);
String evenementNaam = event.getNaam();
//JSoup JAR file benodigd: http://jsoup.org/packages/jsoup-1.7.2.jar

String html = Jsoup.connect("http://localhost:8080/InviteSystem/uitnodigingen/uVoorbeeld.jsp?eventID="+eventID).get().html();
String css = Jsoup.connect("http://localhost:8080/InviteSystem/style.css").get().html();
//System.out.print(html);
	try {
		//BufferedWriter htmlWriter = new BufferedWriter( new FileWriter("C:\\"+evenementNaam+".html") );
		BufferedWriter htmlWriter = new BufferedWriter( new FileWriter("C:\\Users\\Ruben\\school\\InviteSystem\\WebContent\\websites\\"+evenementNaam+".html") );
		BufferedWriter cssWriter = new BufferedWriter( new FileWriter("C:\\Users\\Ruben\\school\\InviteSystem\\WebContent\\websites\\style.css") );
		htmlWriter.write(html);
		htmlWriter.close();
		cssWriter.write(css);
		cssWriter.close();
		out.print("Je bestanden zijn gedownload en in de map websites gezet");
	//	out.print("E:\\Program Files\\Apps\\eclipse\\workspace\\InviteSystem\\WebContent\\websites\\"+evenementNaam+".html"");
	//	out.print("Uw bestanden staan opgeslagen op de volgende locaties: <br/><br/> <b>Html:</b>D:\\"+evenementNaam+".html <br/><b>Css:</b> D:\\style.css");
	} catch(IOException e){ 
		e.printStackTrace(); 
	}
%>		
	</br><br/>
	<a href="eOverzicht.jsp">Klik hier om terug te gaan</a>
	</div>
	

</body>

</html>
